/*
* cookie 操作
*
*/

import Cookies from "js-cookie";

export const COOKIE_TOKEN_KEY = 'user_token';
export const COOKIE_PASSWORD_KEY = 'user_password';
export const MUSIC_COOKIE_TOKEN = 'music_cookie';

// 删除cookie
export const clearAllCookies = (keyNames) => {
    if(keyNames.lenth == 1) {
        Cookies.remove(keyNames[0]);
        return;
    };
    // 清空cookie
    for(let item of keyNames) {
        Cookies.remove(item);
    };
};

// 获取cookie
export const getTokenFromCookie = (keyName) => {
    return Cookies.get(keyName);
};

/*
* 设置cookie
* 
*/
export const saveTokenToCookie = (keyName, token, time) => {
    Cookies.set(keyName, token, { expires: time });
}